package viewModel;

import org.zkoss.bind.annotation.Init;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.Sessions;

import Controller.UserCredentialManager;
import Misc.Variables;
/**
 * Exam View Model
 * @author Rupert
 *
 */
public class ExamViewerViewModel {
	
	private String pdfPath;
	
	@Init
    public void init(){
		UserCredentialManager user = (UserCredentialManager) Sessions.getCurrent().getAttribute(UserCredentialManager.KEY_USER_Model);
		if(user!= null){
		}else{
			Executions.sendRedirect("login.zul");
			return;
		}
		
		Object tmpObject =Sessions.getCurrent().getAttribute(Variables.examPDFPathAttribut);
		if(tmpObject == null){
			Executions.sendRedirect("dashboard.zul");
			return;
		}
		

		Sessions.getCurrent().removeAttribute(Variables.examPDFPathAttribut);
		
		System.out.println("Change");
		String examPDF = tmpObject.toString();
		
		this.pdfPath = examPDF;
    }
		
	/**
	 * @return the pdfPath
	 */
	public String getPdfPath() {
		return pdfPath;
	}

	/**
	 * @param pdfPath the pdfPath to set
	 */
	public void setPdfPath(String pdfPath) {
		this.pdfPath = pdfPath;
	}

}
